package com.retailshop.shopuser.service.impl;

import com.retailshop.shopuser.common.OtherConstants;
import com.retailshop.shopuser.entity.User;
import com.retailshop.shopuser.entity.UserBankInfo;


import com.retailshop.shopuser.mapper.UserMapper;

import com.retailshop.shopuser.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("userService")
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;


    @Override
    public User selectByPrimaryKey(int id) {
        return userMapper.selectByPrimaryKey(id);
    }


    @Override
    public int insertSelective(User record) {
        return userMapper.insertSelective(record);
    }


    @Override
    public int updateByPrimaryKeySelective(User record) {
        return userMapper.updateByPrimaryKeySelective(record);
    }

    /**
     * 根据用户手机号查询用户信息
     *
     * @param user
     * @return
     */
    @Override
    public List<User> selectUserByPhone(User user) {

        if (OtherConstants.RegexpPhone(user.getPhone())) {
            return userMapper.selectUserByPhone(user);
        }

        return null;
    }

    @Override
    public User selectUserByOpenId(String openId) {
        return userMapper.selectUserByOpenId(openId);
    }


    @Override
    public User selectUserByPhone(String phone) {
        return userMapper.queryUserByPhone(phone);
    }


    @Override
    public UserBankInfo selectUserBankByUserId(int userId) {
        return userMapper.selectUserBankInfo(userId);
    }

    @Override
    public List<User> getUserList() {
        return userMapper.getUserList();
    }


}
